define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vppz/vip_card/index' + location.search+'&ids='+Config.package_id,
                    table: 'vppz_vip_card',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                //fixedColumns: true,
                //fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),searchable:false},
						// {field: 'code', title: '会员码', operate: 'LIKE',searchable:false},
						{field: 'vip_package_title', title: '会员卡类型', operate: 'LIKE',searchable:false},
						{field: 'qrcode_url', title: '小程序码',events: Table.api.events.image,formatter: Table.api.formatter.image,searchable:false},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status,custom:{'0':'warning','1':'success'}},//"0":__('Status 0'),
                        {field: 'user.nickname', title: '会员昵称', operate:'BETWEEN',searchable:false},
                        // {field: 'user.avatar_url', title: '会员头像',events: Table.api.events.image,formatter: Table.api.formatter.image,searchable:false},
						{field: 'createtime', title: '制作时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: '更新时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
